//
//  ViewController.m
//  MeiLiYiChu
//
//  Created by mac on 16/2/23.
//  Copyright © 2016年 mac. All rights reserved.
//

#import "ViewController.h"
#import "XSMianViewController.h"
#import "XSBrandViewController.h"

#import "XSCatViewController.h"
#import "XSMYViewController.h"

#import "FLTabBarController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    
    [self createTabBar];
}
+(void)goCustomTabBar
{
    XSTabBarViewController * tabBar =[[XSTabBarViewController alloc]init];
    
    UIWindow * window =[UIApplication sharedApplication].keyWindow;
    window.rootViewController =tabBar;
}

-(void)createTabBar
{
    
    
    XSMianViewController * MainVC =[[XSMianViewController alloc]init];
    UINavigationController * MainNav =[[UINavigationController alloc]initWithRootViewController:MainVC];

    //UIImageRenderingModeAlwaysOriginal 保留原来的状态
//    UIImageRenderingModeAlwaysTemplate 保留最后的状态
    //设置上左下右! 偏移量必须相等
    
    MainVC.tabBarItem.imageInsets  =UIEdgeInsetsMake(5, 0, -5, 0);
    UIImage * homeImg =[[UIImage imageNamed:@"yuike_maintab_home_nor"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    UIImage * homeSelectImg =[[UIImage imageNamed:@"yuike_maintab_home_sel"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    MainVC.tabBarItem.image =homeImg;
    MainVC.tabBarItem.selectedImage =homeSelectImg;
    
    
    
    XSBrandViewController * BrandVC =[[XSBrandViewController alloc]init];
    
    UINavigationController * BrandNav =[[UINavigationController alloc]initWithRootViewController:BrandVC];
    
    BrandVC.tabBarItem.imageInsets  =UIEdgeInsetsMake(5, 0, -5, 0);
    UIImage * homeImg2 =[[UIImage imageNamed:@"yuike_maintab_category_nor"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    UIImage * homeSelectImg2 =[[UIImage imageNamed:@"yuike_maintab_category_sel"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    BrandVC.tabBarItem.image =homeImg2;
    BrandVC.tabBarItem.selectedImage =homeSelectImg2;
    
 
    
    XSCatViewController * CatVC =[[XSCatViewController alloc]init];
    
    UINavigationController * CatNav =[[UINavigationController alloc]initWithRootViewController:CatVC];
    
    CatVC.tabBarItem.imageInsets  =UIEdgeInsetsMake(5, 0, -5, 0);
    UIImage * homeImg3 =[[UIImage imageNamed:@"yuike_maintab_shopcart_nor"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    UIImage * homeSelectImg3 =[[UIImage imageNamed:@"yuike_maintab_shopcart_sel"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    CatVC.tabBarItem.image =homeImg3;
    CatVC.tabBarItem.selectedImage =homeSelectImg3;

    
    XSMYViewController * MYVC =[[XSMYViewController alloc]init];
    
    UINavigationController * MYNav =[[UINavigationController alloc]initWithRootViewController:MYVC];
    MYVC.tabBarItem.imageInsets  =UIEdgeInsetsMake(5, 0, -5, 0);
    UIImage * homeImg4 =[[UIImage imageNamed:@"yuike_maintab_space_nor"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    UIImage * homeSelectImg4 =[[UIImage imageNamed:@"yuike_maintab_space_sel"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    MYVC.tabBarItem.image =homeImg4;
    MYVC.tabBarItem.selectedImage =homeSelectImg4;

    
    UITabBarController * tabBar =[[UITabBarController alloc]init];
    tabBar.viewControllers =@[MainNav,BrandNav,CatNav,MYNav];
//    tabBar.itemImages =@[@"yuike_maintab_home_nor",@"yuike_maintab_category_nor",@"yuike_maintab_shopcart_nor",@"yuike_maintab_space_nor"];
//    tabBar.itemSelectedImages=@[@"yuike_maintab_home_sel",@"yuike_maintab_category_sel",@"yuike_maintab_shopcart_sel",@"yuike_maintab_space_sel"];
    
    UIWindow * window =[UIApplication sharedApplication].keyWindow;
    
    window.rootViewController = tabBar;
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
